import request from "../utils/Request.js";
import api from "../utils/api.js";


export default {
    state: {
        bannerList: [],
        recommendedSongSheetList: [],
        hotSingerList: [],
    },
    mutations: {
        SETBANNERLIST(state, list) {
            state.bannerList = list;
        },
        SETEVERYDAYSONGSHEET(state, list) {
            state.recommendedSongSheetList = list;
        },
        SETHOTSINGERLIST(state, list) {
            state.hotSingerList = list;
        }
    },
    actions: {
        // 获取首页轮播图
        async getBanner({ commit }) {
            let result = await request.get("/banner?type=2");
            if (result.code === 200) {
                commit("SETBANNERLIST", result.banners);
            }
        },
        // 获取每日推荐歌单
        async getEverydayRecommendedSongSheet({ commit }) {
            let result = await request.get(`/top/playlist?limit=30&cat='全部'`);
            if (result.code === 200) {
                commit("SETEVERYDAYSONGSHEET", result.playlists);
            }
            // let result = await request({
            //     url: "/recommend/resource", data: {
            //         cookie: window.localStorage.getItem('cookie')
            //     },
            //     method: "POST"
            // });

            // if (result.code === 200) {
            //     commit("SETEVERYDAYSONGSHEET", result.recommend);
            // }
        },
        // 获取热门歌手
        async getHotSingerList({ commit }) {
            let res = await api.getHotSinger(10);
            commit("SETHOTSINGERLIST", res);
        },

    }
};